#include "stdafx.h"
#include "ineedthis.h"

// Called in initialize
void MyList::setRect(RECT *rc)
{
	// Make the rectangle a default blank rectangle
	memset(&m_rc, 0, sizeof(RECT));
	// Copy the contents of the argument rect to the member rect
	memcpy(&m_rc, rc, sizeof(RECT));
}

// Called in wm_paint
void MyList::drawRect(HDC hdc)
{
	// Just draws a rectangle that borders the whole list
	Rectangle(hdc, m_rc.left, m_rc.top, m_rc.right, m_rc.bottom);

	// Draws a item for each item of the m_itemlist
	std::list<MyItem *>::iterator iter;
	for (iter = m_itemlist.begin(); iter != m_itemlist.end(); iter++)
	{
		(*iter)->draw(hdc);
	}


}

void MyList::addItem(MyItem *item)
{
	m_itemlist.push_back(item);
}

void MyItem::setRect(RECT *rc)
{
	memset(&m_rc, 0, sizeof(RECT));
	memcpy(&m_rc, rc, sizeof(RECT));
}

void MyItem::setText(char *text)
{
	m_string = std::string(text);
}

void MyItem::draw(HDC hdc)
{
	DrawText(hdc, m_string.c_str(), m_string.length(), &m_rc, NULL);
}

